package view;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import control.MainWindowController;

@SuppressWarnings("serial")
public class FunctionalPanel extends JPanel{
	private JLabel	messageLabel;
	private JButton obstaclesButton;
	private JButton points;
	private JButton quadtreeButton;
	private JButton routeButton;
	private JButton sendButton;
	private JButton startButton;
	
	public FunctionalPanel(MainWindowController controller) {
		messageLabel = new JLabel("Please, insert the obstacles!");
		
		obstaclesButton = new JButton();
		obstaclesButton.addActionListener(controller);
		obstaclesButton.setText("Obstacles Insertion ok!");
		
		points = new JButton();
		points.addActionListener(controller);
		points.setText("Start/End Points ok!");
		points.setEnabled(false);
		
		quadtreeButton = new JButton();
		quadtreeButton.addActionListener(controller);
		quadtreeButton.setText("Make Quadtree");
		quadtreeButton.setEnabled(false);
		
		routeButton = new JButton();
		routeButton.addActionListener(controller);
		routeButton.setText("Make Route");
		routeButton.setEnabled(false);
		
		sendButton = new JButton();
		sendButton.addActionListener(controller);
		sendButton.setText("Send to Robot");
		sendButton.setEnabled(false);
		
		startButton = new JButton();
		startButton.addActionListener(controller);
		startButton.setText("Start");
		startButton.setEnabled(false);
		
		GroupLayout layout = new GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
				.addComponent(messageLabel, 220, 220, 220)
				.addComponent(obstaclesButton, 200, 200, 200)
				.addComponent(points, 200, 200, 200)
				.addComponent(quadtreeButton, 200, 200, 200)
				.addComponent(routeButton, 200, 200, 200)
				.addComponent(sendButton, 200, 200, 200)
				.addComponent(startButton, 200, 200, 200));
		layout.setVerticalGroup(layout.createSequentialGroup()
				.addGap(30)
				.addComponent(messageLabel, 30, 30, 30)
				.addGap(30)
				.addComponent(obstaclesButton, 30, 30, 30)
				.addGap(30)
				.addComponent(points, 30, 30, 30)
				.addGap(30)
				.addComponent(quadtreeButton, 30,30,30)
				.addGap(30)
				.addComponent(routeButton, 30, 30, 30)
				.addGap(30)
				.addComponent(sendButton, 30, 30, 30)
				.addGap(30)
				.addComponent(startButton, 30, 30, 30));
		
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);
	}
	
	public JButton getQuadtreeButton() {
		return quadtreeButton;
	}

	public JButton getObstaclesButton(){
		return this.obstaclesButton;
	}

	public JButton getRouteButton() {
		return routeButton;
	}

	public JButton getSendButton() {
		return sendButton;
	}

	public JButton getStartButton() {
		return startButton;
	}

	public JButton getPointsButton(){
		return this.points;
	}

	public void setMessageLabel(String message) {
		this.messageLabel.setText(message);
	}
}
